package com.ZengQi.event.util;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 * 数据库增删改操作的工具类
 */
public class UpdateUtils {
    public  static boolean update(String sql, Object... args) {
        Connection conn=null;
        PreparedStatement ps=null;
        try {
             conn=JDBCUtils.getConnection();
             ps=conn.prepareStatement(sql);

            for(int i=0;i<args.length;i++){
                ps.setObject(i+1,args[i]);
            }
            int i = ps.executeUpdate();
            if(i==1){
                return true;
            }

        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            JDBCUtils.close(null,ps,conn);

        }
            return false;
    }





}